package com.gen.method;

import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModelException;
import java.util.List;

public class RemoveFirstCapWordMethodModel implements TemplateMethodModel {
	@SuppressWarnings("rawtypes")
	public Object exec(List arguments) throws TemplateModelException {
		if (arguments.size() != 1) {
			throw new TemplateModelException("Wrong arguments");
		}
		String str = (String) arguments.get(0);
		return removeFirstCap(str);
	}

	public static String removeFirstCap(String word) {
		int capCount = 0;
		int index = 0;
		for (int i = 0; i < word.length(); ++i) {
			if ((word.charAt(i) + "").matches("[A-Z]{1}")) {
				++capCount;
			}
			if (capCount == 2) {
				index = i;
				break;
			}
		}
		return word.substring(index);
	}
}